using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponReward : MonoBehaviour
{
    //随机武器
    public GameObject[] weaponObj;
    //获取特效
    public GameObject getEff;
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            int weaponIndex = Random.Range(0, weaponObj.Length);
            Player player = other.GetComponent<Player>();
            player.ChangeWeapon(weaponObj[weaponIndex]);

            GameObject eff = Instantiate(getEff, transform.position, transform.rotation);
            AudioSource audioSource = eff.GetComponent<AudioSource>();
            audioSource.volume = GameDataManager.Instance.musicData.soundValue;
            audioSource.mute = GameDataManager.Instance.musicData.isOpenSound;
            Destroy(this.gameObject);
        }
    }
}
